﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace EmailExtractor
{
    class Program
    {
        static void Main()
        {
            string text = "a valid hello@gyuvetch.bg is sending email to the non valid email - alabala.alabala@.alabala" + 
                "and then the mighty valid email shows up as lsfh484h_df4.adf-dfdsgfg@kdjfsjlfl.eu";
            string pattern = @"\b[A-Za-z0-9\._-]+@[A-Za-z0-9\._-]+\.[A-Za-z]{2,4}\b";
            Regex regex = new Regex(pattern);

            Match match = regex.Match(text);
            while (match.Success)
            {
                Console.WriteLine(match.Value);
                match = match.NextMatch();
            }
        }
    }
}
